/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 周斌
 * Date: 2024-01-26
 * Time: 19:58
 */
public class ListNode {
    public int val;
    public ListNode next;
    public ListNode(int val) {
        this.val = val;

    }
    public ListNode() {
        this.val = val;
    }
    public ListNode middleNode(ListNode head) {
        //定义两个节点，一个快结点，一个慢结点
        ListNode slow = head;
        ListNode fast = head;
        //当fast != null && fast.next != null，结束循环。
        while(fast != null && fast.next != null) {
            //fast走两步，slow走一步
            fast = fast.next.next;
            slow = slow.next;
        }
        return slow;
    }

    public static void main(String[] args) {
        ListNode listNode = new ListNode();

    }
}
